//
//  MyPage_headerView.m
//  sellHouse
//
//  Created by 李 佳伟 on 2018/11/21.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "MyPage_headerView.h"
#import "JTCSM.h"

static CGFloat logosize = 64;
static CGFloat labelHeight = 18;


@interface MyPage_headerView ()
{
    UIImageView *logoImageV;
    UILabel *nameLabel;
    UIImageView *editImageV;
   
    
}

@end

@implementation MyPage_headerView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)init{
    self = [super init];
    if (self) {
        
        self.frame = CGRectMake(0, Height_NavBar-2, KSCREENWidth, 153);
        self.backgroundColor = [UIColor whiteColor];
        UIImageView *backImageV = [[UIImageView alloc]initWithFrame:self.bounds];
        backImageV.image = [UIImage imageNamed:@"bg.png"];
        [self addSubview:backImageV];
        
        logoImageV = [[UIImageView alloc]initWithFrame:CGRectMake((self.frame.size.width-logosize)/2, 30, logosize, logosize)];
        logoImageV.image = [UIImage imageNamed:@"moren_logo.jpg"];
        [df layerWithView:logoImageV radius:logosize/2 width:0 color:nil];
        [self addSubview:logoImageV];
        
        nameLabel = [UILabel new];
        nameLabel.textColor = [UIColor whiteColor];
        nameLabel.font = [UIFont systemFontOfSize:16];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:nameLabel];
        
        editImageV = [UIImageView new];
        editImageV.image = [UIImage imageNamed:@"modify_name.png"];
        [self addSubview:editImageV];
        self.userInteractionEnabled = YES;
        backImageV.userInteractionEnabled = YES;
        editImageV.userInteractionEnabled = YES;
        [df addTapGestureRecognizerWithTarget:self action:@selector(eidtName) andaddView:editImageV];
        
    }
    
    
    return self;
}

- (void)setValueWithName:(NSString *)name logo:(NSString *)logo{
    
    CGRect rect = [df labelHeightWithContent:name height:labelHeight label:nameLabel];
    nameLabel.frame = CGRectMake((KSCREENWidth-rect.size.width)/2, KVIEW_Y(logoImageV)+10, rect.size.width, labelHeight);
    nameLabel.text = name;
    editImageV.frame = CGRectMake(KVIEW_X(nameLabel)+5, nameLabel.frame.origin.y, labelHeight, labelHeight);
    if (![logo isEqualToString:@""]) {
        logoImageV.image = [UIImage imageNamed:logo];
    }
    
}

//编辑按钮
- (void)eidtName{
    
    [self.delegate gotoEidt];
}

@end
